    <?php
	if(isset($_GET["id"]))
	{
		include_once("../../DataProvider.php");
		$idBill = $_GET["id"];
	
		$sql = "select * from tbl_bills where IDBill = $idBill";
		$result = DataProvider::ExecuteQuery($sql);
		if($row = mysql_fetch_array($result))
		{
			
			$listGame = "";
			$listGameID = "";
			$Price = 0;
			$sql1 = "select IDGame from tbl_detailbill where IDBill = $idBill";
			$result1 = DataProvider::ExecuteQuery($sql1);
			while($row1 = mysql_fetch_array($result1))
			{
				$listGame = $listGame. "," .$row1["IDGame"];
				
			}
			$listGame = substr($listGame,1);
			$sql2 = "select * from tbl_games where GameID in (".$listGame." )";
			$result2 = DataProvider::ExecuteQuery($sql2);
			$num = mysql_num_rows($result2);
			while($row2 = mysql_fetch_array($result2))
			{
				$temp = $row2["GameLink"];
				$listGameID = $listGameID.",".substr($temp,strpos($temp,'id')+2,9) ;
				$Price += (float)$row2["Price"];
			}
			$listGameID = substr($listGameID,1);
			$Price = number_format($Price,0,'.',',');
			$name =	$row["UserName"];
			 header('Content-type: application/txt');
    		header('Content-Disposition: attachment; filename="'.$name.'.txt"');
			$time = strtotime($row["CreateDate"]);
			$date = date("d-m-Y",$time);
			echo "\r\n";
			echo "Họ tên/Email: ".$name."\r\n";
			echo "Ngày đặt: ".$date."\r\n";
			echo "SĐT: ".$row["Phone"]."\r\n";
			echo "Tiền thanh toán: ".$Price." VNĐ\r\n";
    		//echo "\nDS game: ".$listGame;
			echo "\nDS game: ".$listGameID;


		}
	}
    ?>